#!/usr/bin/env node

import { program } from 'commander'
import { generateInitFiles } from '@/modules/init';
import { check } from '@/modules/check';
import { generate } from '@/modules/generate';
import { createSQL } from '@/modules/sql';
import inquirer from 'inquirer';
import { Options } from './constant';

program
    .command('init')
    .action(() => {
        generateInitFiles();
    });

program
    .command('check')
    .action(() => check());

program
    .version(require('../package.json').version, '-v, --version')    
    .command('generate')
    .action(() => {
            inquirer.prompt([
                {
                    type: 'list',
                    name: 'option',
                    message: 'which template to clone',
                    choices: Object.values(Options),
                }
            ]).then(({ option }) => {
                generate(option);
            })
    });

program
    .command('sql')
    .action(() => {
        // 确认配置文件合法
        const combinedJSON = check();
        createSQL(combinedJSON);
    });

program.parse(process.argv)
